const express = require('express');
const cors = require('cors');

const router = require('./router/index');
const app = express();
const morgan = require('morgan');

// 跨域中间件
app.use(cors());

// 日志中间件
app.use(morgan('dev'));

// 路由
app.use('/api', router);

// all所有请求方式
const PORT = process.env.PORT || 3001;

app.listen(PORT, () => {
	console.log(`Server is running at http://localhost:${PORT}`);
});
